import essayCard from "@/components/essayCard/essayCard.vue";
import personCard from "@/components/personCard/personCard.vue";
import * as allUrls from '../../utils/allUrls.js'
import { hotlive,hotuser } from "../../api/index.js";
export default {
    name: 'home',
    inject: ['reload'],
    components: {essayCard, personCard},
    data() {
        return {
            indexPic: '',
            personInfo: [],
            essayInfo: {},
            loading1: false,
			userlist:[],
			livelist:[],
        }
    },
    methods: {
        //随机数组方法
        randomMath() {
            return Math.random() > .5 ? -1 : 1;
        },
		toLive(val) {
			debugger
			this.$router.push({
				path: '/liveRoom',
				query: {
					hostName: val
				}
			})
		},
        //获取人物卡片信息
        getTopListPerson() {
            allUrls.getUserByScore({
                //    此处username可不传，查全部
            }, "post").then(res => {
                return res.json();
            }).then(data => {
                this.personInfo = data.data;
            }).catch(err => {
                console.log(err);
                this.$message.error("获取推荐人物出错！");
            })
        },
        //点击推荐人物
        toPersonalCenter(val) {
            this.$router.push({path: '/personalCenter', query: {username: val}})
        },
        // 跳转至注册页
        toReg() {
            this.$router.push('/register')
        },
        // 跳转至文章内容页
        toEssay(val) {
            this.$router.push({path: '/liveRoom', query: {hostName: val}})
        },
        //跳转至“更多文章”
        toMoreEssay() {
            this.$router.push('/liveHall')
        },
    },
    mounted() {
        this.reload();
/*        this.getIndexPic();
        this.getIndexEssay();
        this.getTopListPerson(); */
		hotlive().then(response => {
			
			this.livelist = response.rows;
		});
		hotuser().then(response => {
			this.userlist = response.rows;
		});
    }
}
